<!DOCTYPE html PUBLIC 
    "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
<html 
	xmlns="http://www.w3.org/1999/xhtml" 
	xmlns:ui="http://java.sun.com/jsf/facelets" 
	xmlns:h="http://java.sun.com/jsf/html" 
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:t="http://myfaces.apache.org/tomahawk"> 


	<ui:composition template="t_loggedin.xhtml">


	<ui:define name="javascript">
		<script type="text/javascript">

			function cbQueueSelected() {
				document.forms["sendForm"]["sendForm:cb_topic"].checked = false;
				document.forms["sendForm"]["sendForm:cb_defdest"].checked = false;	
			}

			function cbTopicSelected() {
				document.forms["sendForm"]["sendForm:cb_queue"].checked = false;	
			}

			function fOtherDestination() {
				document.forms["sendForm"]["sendForm:cb_defdest"].checked = false;				
			}

			function fDefaultDestination() {
				document.forms["sendForm"]["sendForm:otherDest"].value = "";
				document.forms["sendForm"]["sendForm:cb_queue"].checked = false;				
				document.forms["sendForm"]["sendForm:cb_topic"].checked = true;
			}

    		
		</script> 
	</ui:define>	

	<ui:define name="menu">
		<h:form>
			<table class="leftmenu">
				<tbody>
					<!-- Logo -->
					<tr class="leftmenuheader">
						<th colspan="2"></th>
					</tr>
					<tr class="leftmenu">
						<td colspan="2" class="image">
							<h:graphicImage value="images/broker-active.png" rendered="#{brokerBean.started}"/>
							<h:graphicImage value="images/broker-inactive.png" rendered="#{!brokerBean.started}"/>
						</td>
					</tr>				
					
					<!-- Status overview -->					
					<tr class="leftmenuheader">
						<th colspan="2"><h:outputText value="#{msgs['menu.heading.status']}" /></th>
					</tr>
					<tr class="leftmenu">
						<th><h:outputText value="#{msgs['mq.menu.status']}" /></th>
						<td><h:outputText value="#{brokerBean.status}" /></td>
					</tr>
					

					<!-- Actions -->
					<tr class="leftmenuheader">
						<th colspan="2">
							<h:outputText value="#{msgs['menu.heading.actions']}" />
						</th>
					</tr>				
					<tr class="leftmenu">
						<td colspan="2">
							<h:panelGroup rendered="#{!brokerBean.queueView}">
								<h:commandLink value="#{msgs['mq.menu.action.queues']}" action="${brokerBean.toggleQueueView}"/>
							</h:panelGroup>
							<h:panelGroup rendered="#{brokerBean.queueView}">
								<h:commandLink value="#{msgs['mq.menu.action.queues.hide']}" action="${brokerBean.toggleQueueView}"/>
							</h:panelGroup>							
						</td>					
					</tr>		
					<tr class="leftmenu">
						<td colspan="2">
							<h:panelGroup rendered="#{!brokerBean.topicView}">
								<h:commandLink value="#{msgs['mq.menu.action.topics']}" action="${brokerBean.toggleTopicView}"/>
							</h:panelGroup>
							<h:panelGroup rendered="#{brokerBean.topicView}">
								<h:commandLink value="#{msgs['mq.menu.action.topics.hide']}" action="${brokerBean.toggleTopicView}"/>
							</h:panelGroup>
						</td>
					</tr>
					<tr class="leftmenu">
						<td colspan="2">
							<h:panelGroup rendered="#{!brokerBean.newQueueView}">
								<h:commandLink value="#{msgs['mq.menu.action.newqueue']}" action="${brokerBean.toggleNewQueueView}"/>
							</h:panelGroup>
							<h:panelGroup rendered="#{brokerBean.newQueueView}">
								<h:commandLink value="#{msgs['mq.menu.action.newqueue.hide']}" action="${brokerBean.toggleNewQueueView}"/>
							</h:panelGroup>							
						</td>					
					</tr>		
					<tr class="leftmenu">
						<td colspan="2">
							<h:panelGroup rendered="#{!brokerBean.newTopicView}">
								<h:commandLink value="#{msgs['mq.menu.action.newtopic']}" action="${brokerBean.toggleNewTopicView}"/>
							</h:panelGroup>
							<h:panelGroup rendered="#{brokerBean.newTopicView}">
								<h:commandLink value="#{msgs['mq.menu.action.newtopic.hide']}" action="${brokerBean.toggleNewTopicView}"/>
							</h:panelGroup>							
						</td>					
					</tr>		
					<tr class="leftmenu">
						<td colspan="2">
							<h:panelGroup rendered="#{!brokerBean.sendView}">
								<h:commandLink value="#{msgs['mq.menu.action.send']}" action="${brokerBean.toggleSendView}"/>
							</h:panelGroup>
							<h:panelGroup rendered="#{brokerBean.sendView}">
								<h:commandLink value="#{msgs['mq.menu.action.send.hide']}" action="${brokerBean.toggleSendView}"/>
							</h:panelGroup>
						</td>
					</tr>
					
					<!-- Control -->
					<tr class="leftmenuheader">
						<th colspan="2">
							<h:outputText value="#{msgs['menu.heading.control']}" />
						</th>
					</tr>	
					<tr class="leftmenu">
						<td align="center">
							<h:commandButton 
									id="mqStartButton"
									disabled="#{brokerBean.started}"
									action="#{brokerBean.getStatus}" 
									actionListener="#{brokerStopStartActionHandler.startBroker}"
									value="#{msgs['mq.menu.action.start']}">
							</h:commandButton>
						</td>
						<td align="center">
							<h:commandButton
							        id="mqStopButton"
							        disabled="#{!brokerBean.started}" 
									action="#{brokerBean.getStatus}" 
									actionListener="#{brokerStopStartActionHandler.stopBroker}"
									value="#{msgs['mq.menu.action.stop']}">
							</h:commandButton>
						</td>
					</tr>					
				</tbody>
			</table>
		</h:form>
	</ui:define>

	<ui:define name="body">
		<ui:decorate template="faces/broker_stats.xhtml" />
		<ui:decorate template="faces/broker_queues.xhtml" />
		<ui:decorate template="faces/broker_topics.xhtml" />
		<ui:decorate template="faces/broker_newqueue.xhtml" />
		<ui:decorate template="faces/broker_newtopic.xhtml" />
		<ui:decorate template="faces/broker_send.xhtml" />
	</ui:define>

</ui:composition>

</html>